// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import App from './App'
import router from './router'
import store from './store'
import '../static/init.css'
import VueSocketio from 'vue-socket.io'

import VueAxios from 'vue-axios'

Vue.use(VueAxios, axios)

Vue.use(new VueSocketio({
  debug: false,
  connection: 'http://localhost:8881'
}))

Vue.config.productionTip = false
Vue.config.errorHandler = (err, vm, info) => {
  const obj = {
    'err': err,
    'vm': vm,
    'info': info
  };
  Vue.axios.post('http://localhost:3000/admin/postError', { type: 'errorHandler', err: obj }).then(response => { })
}
window.addEventListener('error', (event) => {
  Vue.axios.post('http://localhost:3000/admin/postError', { type: 'error', err: event }).then(response => { })
}, true);

/* eslint-disable no-new */
new Vue({
  el: '#app',
  render: c => c(App),
  router,
  store,
  mounted () {
    document.dispatchEvent(new Event('render-active'));
    document.addEventListener('scroll', () => {
      this.$store.commit('scrollEvent')
    }, false);
  }
})